
const Preload =require("./preload");
class Gaming extends Preload{
  constructor(){
    super();
  }
  setBg(){
    let bg=game.add.image(0,0,"bg_index")
    bg.width=this.bw;
    bg.height=this.bh;
  }
  setBtn(){
    this.startBtn=game.add.group();
    console.log(this.bw);
    this.startBtn.x=90;
    this.startBtn.y=this.bh*0.9-80;
    let bg_btn=this.startBtn.create(0,0,"btn_start");
    let centerH=this.startBtn.height/2;
    let arrow=this.startBtn.create(20,this.startBtn.height/2,"btn_arrow");
    arrow.anchor.setTo(0.5,0.5);
    arrow.alpha=1;
    let tween=game.add.tween(arrow).to({x:200,alpha:0},2000,Phaser.Easing.Linear.None,true,0,-1);
    let tween1=game.add.tween(arrow).to({x:60,alpha:0},1000,Phaser.Easing.Linear.None,true,0);
    tween.start();
    bg_btn.inputEnabled=true;
    bg_btn.events.onInputDown.add(v=>{
      game.state.start("Playing")
    })
    // tween.onComplete.add()
  }
  create(){
    document.querySelector(".preDog").style.display="none";
    this.setBg();
    this.setBtn();
  }
}

module.exports = Gaming;